import { ETaskState } from "GameLoop/DecisionMaking/TaskDeclare/type";
import { ATaskAdapter } from ".";
 
import { PowerCreepArgHelper } from "utils/helper/Z_PowerCreepArgHelper";

export class TerminalTaskAdapter extends ATaskAdapter<"terminal">
{
    // constructor(context:IContextGetter,world:WorldGetter)
    // {
    //     super(context,world);
       
    // }
 
    public bindTasks(room: Room, tasks:ITaskDeclare["terminal"][],customCheck:IConditionFunction): void 
    {
        for(const task of tasks)
        {
            if(customCheck(room as Required<Room>,task) == OK )
            {
                room.deleteTaskById(task.id,"terminal");
               
            }
            else if(ETaskState.Complete == this.checkState(room,task))
            {
                //global.Log.Info(`${room.name} room ${task.id} check 已经完成`);
                room.deleteTaskById(task.id,"terminal");
              
            }
           // global.Log.Info(`${room.name} room ${task.id} check 未完成`);
            break;
        }
    }

    protected checkState(room:Room,task:ITaskDeclare["terminal"]):ETaskState
    {
        if(task.data.type=="send")
        {

        }
        else 
        {
            if((task.data.arg as IDealTask).amount ==0)
            {
                return ETaskState.Complete
            }
        }
        return  ETaskState.Running;
    }
    
}